﻿//--------------------------------------------------------------
//
//作    者：蒙孝宗
//功能描述：MySQL数据库操作辅助类
//创建时间：2012-02-12
//修改记录：
//版    本：V1.0
//
//--------------------------------------------------------------

using System.Data;
using MySql.Data.MySqlClient;

namespace DbHelper.Driver
{
    public class MySQLDriver : IDriver
    {
        MySqlConnection connection;
        MySqlCommand command;
        MySqlDataAdapter dataAdapter;
        MySqlCommandBuilder commandBuilder;


        public void Connect(string connectionString)
        {
            connection = new MySqlConnection(connectionString);
            command = connection.CreateCommand();
            dataAdapter = new MySqlDataAdapter(command);
            commandBuilder = new MySqlCommandBuilder(dataAdapter);
        }

        public IDriver CreateInstance()
        {
            return new MySQLDriver();
        }

        public IDbConnection DbConnection
        {
            get { return connection; }
        }

        public IDbCommand DbCommand
        {
            get { return command; }
        }

        public IDbDataAdapter DbDataAdapter
        {
            get { return dataAdapter; }
        }
    }
}
